<?
session_start();

require_once('config.php');
require_once('class/cls_user.php');

$user		= new cls_user();


if (count($_POST) > 0)
{
	if (($_POST['username']=="admin") && ($_POST['userpassword'] == admin))
	{		
		$_SESSION['username'] = $_POST['username'];
		Header("location: admin.php");
		exit();
	}
	else
	{
		$errmsg = "Wrong User Name or Password!";
	}
}
else
	{
		$errmsg = "Wrong User Name or Password!";
	}
if (isset($_POST['cname']))
        {
		
		$object = $user->c_sign_in($_POST);

//print_r ($object);

		if (!empty($object)) 
			{
				$_SESSION['username'] 	= $_POST['cname'];
				$_SESSION['id']		=	$object['cid'];
				Header("location: selection.php");			
			}
			
		else
			{
				echo "<br><center><font color=red size=4>Invalid User name or password, please <a href='new-login.php'> click here to register</a></font></center>";
			}
   		}//if
   
   
   
class right
	{
	function showright()	
	{	
?>		
<TABLE cellSpacing=0 cellPadding=3 width="100%" bgcolor="#eee8e8">
		<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" style="margin-bottom: 0px; margin-top: 0px; ">
             
              <TR bgcolor="#CCCCCC">
                <TD colspan="3" height="25px" align="center" class="boxti">&nbsp;ADMIN LOGIN</TD>
				</TR>
				<tr>
    <td colspan="3" align="center" ><font color="red"><strong><?= ((isset($errmsg)) ? $errmsg : "") ?></strong></font></td>
  </tr>
              <tr>
					<td width="50px" align="center" class="qcontact">Name</td>
					<td>:</td>
					<td align="center">
					  <input type="text" name="username" size="8" />
					</td>
			    </tr>
              <tr>
					<td width="60px" align="center" class="qcontact">Password</td>
					<td>:</td>
					<td align="center">
					  <input type ="password" name="userpassword" size="8" />
					</td>
			    </tr>
              <TR>
                <TD colspan="3" align="center"><input type="submit" value = "Sign In >>>"></TD>
              </TR></form>
          </TABLE><BR>
		 
<?
	}
}
?>
